package com.ch.ba01;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author chenhong
 * @version 1.0.0
 * @ClassName Student.java
 * @Description TODO
 * @createTime 2020年12月10日 20:55:00
 */

/**
 *
 */
@Component(value = "MyStudent")
public class Student {
    @Value("chen")
    private String name;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", school=" + school2 +
                '}';
    }

    @Value("30")
    private Integer age;

/*    @Autowired(required = false)
    @Qualifier(value = "MySchool")*/

    //@Resource先ByName 后ByType
    @Resource(name = "school")
    private School school2;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    @Value("18")
    public void setAge(Integer age) {
        System.out.println("setAge " + age);
        this.age = age;
    }

    public Student() {
        System.out.println("Student 的无参数构造========");
    }
}
